cmake_minimum_required(VERSION 3.22)
project(ffmpeg_demo C)

set(CMAKE_C_STANDARD 99)

#include_directories(D:/Dev/ClionProjects/ffmpeg-shared/include)
#LINK_DIRECTORIES(D:/Dev/ClionProjects/ffmpeg-shared/lib)
include_directories(D:/msys64/usr/local/ffmpeg/include)
LINK_DIRECTORIES(D:/msys64/usr/local/ffmpeg/lib)

include_directories(D:/Dev/ClionProjects/SDL2/include/SDL2)
LINK_DIRECTORIES(D:/Dev/ClionProjects/SDL2/lib)

include_directories(D:/Dev/ClionProjects/SDL2_image/include/SDL2)
LINK_DIRECTORIES(D:/Dev/ClionProjects/SDL2_image/lib)

#add_executable(ffmpeg_demo examples/demux_decode.c)
#add_executable(ffmpeg_demo)
#file(GLOB sources CONFIGURE_DEPENDS ffmpeg_examples/*.c ffmpeg_examples/*.h)
#target_sources(ffmpeg_demo PUBLIC main.c ${sources})
#
#target_link_libraries(
#        ffmpeg_demo
#        avcodec
#        avdevice
#        avfilter
#        avformat
#        avutil
#        postproc
#        swresample
#        swscale
#        mingw32
#        SDL2main
#        SDL2
#)

add_executable(decode_audio1 examples/decode_audio.c)
target_link_libraries(
        decode_audio1
        avcodec
        avutil
)

add_executable(show_metadata ffmpeg_examples/show_metadata.c)
target_link_libraries(
        show_metadata
        avformat
        avutil
)

add_executable(find_best_stream ffmpeg_examples/find_best_stream.c)
target_link_libraries(
        find_best_stream
        avformat
        avutil
)

add_executable(record_audio ffmpeg_examples/record_audio.c)
target_link_libraries(
        record_audio
        avdevice
        avformat
        avutil
        avcodec
)

add_executable(record_audio_sub_thread ffmpeg_examples/record_audio_sub_thread.c)
target_link_libraries(
        record_audio_sub_thread
        avdevice
        avformat
        avutil
        avcodec
)


add_executable(play_pcm ffmpeg_examples/play_pcm.c)
target_link_libraries(
        play_pcm
        avdevice
        avformat
        avutil
        avcodec
        mingw32
        SDL2main
        SDL2
)

add_executable(pcm_to_wav ffmpeg_examples/pcm_to_wav.c)
target_link_libraries(
        pcm_to_wav
        avformat
        avutil
)

add_executable(play_wav ffmpeg_examples/play_wav.c)
target_link_libraries(
        play_wav
        mingw32
        SDL2main
        SDL2
)

add_executable(resample_audio ffmpeg_examples/resample_audio.c)
target_link_libraries(
        resample_audio
        swresample
        avutil
)

add_executable(encode_audio ffmpeg_examples/encode_audio.c)
target_link_libraries(
        encode_audio
        avcodec
        avutil
)

add_executable(decode_audio ffmpeg_examples/decode_audio.c)
target_link_libraries(
        decode_audio
        avcodec
        avutil
)

add_executable(record_video ffmpeg_examples/record_video.c)
target_link_libraries(
        record_video
        avformat
        avcodec
        avdevice
        avutil
)


add_executable(push_to_rtmp_server ffmpeg_examples/push_to_rtmp_server.c)
target_link_libraries(
        push_to_rtmp_server
        avformat
        avcodec
        avutil
)

add_executable(encode_video ffmpeg_examples/encode_video.c)
target_link_libraries(
        encode_video
        avcodec
        avutil
)

add_executable(decode_video ffmpeg_examples/decode_video.c)
target_link_libraries(
        decode_video
        avcodec
        avutil
)

add_executable(convert_raw_video ffmpeg_examples/convert_raw_video.c)
target_link_libraries(
        convert_raw_video
        avcodec
        swscale
        avutil
)

add_executable(flv_parser ffmpeg_examples/flv_parser.c)
target_link_libraries(
        flv_parser
)

# player simple
add_executable(player_simple player_simple/player_simple.c)
target_link_libraries(
        player_simple
        avcodec
        avdevice
        avfilter
        avformat
        avutil
        postproc
        swresample
        swscale
        mingw32
        SDL2main
        SDL2
)

# player video
add_executable(player_video player_video/player_video.c)
target_link_libraries(
        player_video
        avcodec
        avdevice
        avfilter
        avformat
        avutil
        postproc
        swresample
        swscale
        mingw32
        SDL2main
        SDL2
)

# player audio
add_executable(player_audio player_audio/player_audio.c)
target_link_libraries(
        player_audio
        avcodec
        avdevice
        avfilter
        avformat
        avutil
        postproc
        swresample
        swscale
        mingw32
        SDL2main
        SDL2
)

# player audio&video
add_executable(player_audio_video player_audio_video/player_audio_video.c)
target_link_libraries(
        player_audio_video
        avcodec
        avdevice
        avfilter
        avformat
        avutil
        postproc
        swresample
        swscale
        mingw32
        SDL2main
        SDL2
)

# sdl version
add_executable(sdl_version sdl_examples/sdl_version.c)
target_link_libraries(
        sdl_version
        mingw32
        SDL2main
        SDL2
)

add_executable(sdl_helloworld sdl_examples/sdl_helloworld.c)
target_link_libraries(
        sdl_helloworld
        mingw32
        SDL2main
        SDL2
)

add_executable(sdl_keypress sdl_examples/sdl_keypress.c)
target_link_libraries(
        sdl_keypress
        mingw32
        SDL2main
        SDL2
)

# sdl extension
add_executable(loading_other_image_formats sdl_examples/loading_other_image_formats.c)
target_link_libraries(
        loading_other_image_formats
        mingw32
        SDL2main
        SDL2
        SDL2_image
)

add_executable(texture_loading_and_rendering sdl_examples/texture_loading_and_rendering.c)
target_link_libraries(
        texture_loading_and_rendering
        mingw32
        SDL2main
        SDL2
        SDL2_image
)